/*
 * @(#)OgnlSetPropertyAccessor.java $version 2010. 8. 11
 *
 * Copyright 2007-2010 NHN Corp. All rights Reserved. 
 * NHN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.nhncorp.usf.core.ognl;

import java.util.Map;
import java.util.Set;

import ognl.ObjectPropertyAccessor;
import ognl.OgnlException;

/**
 * The Class OgnlSetPropertyAccessor.
 * 
 * @author MiddleWare Platform Development Team
 */
class OgnlSetPropertyAccessor extends ObjectPropertyAccessor {

	/**
	 * Instantiates a new ognl set property accessor.
	 */
	OgnlSetPropertyAccessor() {
		super();
	}

	/**
	 * {@inheritDoc}
	 */
	@SuppressWarnings("unchecked")
	public Object getProperty(Map context, Object target, Object name) throws OgnlException {
		if (name instanceof Number && target instanceof Set) {
			return null;
		} else {
			return super.getProperty(context, target, name);
		}
	}

	/**
	 * {@inheritDoc}
	 */
	@SuppressWarnings("unchecked")
	public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException {
		if (name instanceof Number && target instanceof Set) {
			((Set) target).add(value);
		} else {
			super.setProperty(context, target, name, value);
		}
	}
}
